﻿using System;

namespace ComputedTable.Version10
{
    [Serializable]
    public class ComputedTableException : Exception
    {
        public string Row { get; private set; }
        public string Column { get; private set; }

        public ComputedTableException(string message)
            : base(message)
        {
        }

        public ComputedTableException(string message, string Row, string Column)
            : base(message)
        {
            this.Row = Row;
            this.Column = Column;
        }

        public ComputedTableException(string message, string Row, string Column, Exception innerException)
            : base(message, innerException)
        {
            this.Row = Row;
            this.Column = Column;
        }

        public override string ToString()
        {
            return string.Format("Cell: [{0},{1}]\n{2}", this.Row, this.Column, base.ToString());
        }

        public override void GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context)
        {
            info.AddValue("Row", this.Row);
            info.AddValue("Column", this.Column);
            base.GetObjectData(info, context);
        }
    }
}
